package com.mall.huohuo.service.member;/**
 *
 */

import com.mall.huohuo.common.security.SecurityUtils;
import com.mall.huohuo.common.domain.HuohuoUser;
import com.mall.huohuo.service.auth.domain.OAuthResult;
import com.mall.huohuo.service.auth.param.OAuthParam;
import com.mall.huohuo.service.auth.service.OAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class AuthServiceImpl implements OAuthService {
    /**
     * 用户认证服务
     *
     * @param authParam 认证的参数
     * @return 用户认证的结果
     */
    @Override
    public OAuthResult login(OAuthParam authParam) {
        HuohuoUser huohuoUser = new HuohuoUser();
        huohuoUser.setId(1L)
                .setName("测试名字");
        final String token = SecurityUtils.createUserAccessToken(huohuoUser);
        final String userRefreshToken = SecurityUtils.createUserRefreshToken(huohuoUser);
        return new OAuthResult().setToken(token).setSuccess(true).setRefreshToken(userRefreshToken);
    }

}
